package com.zhuojy.equity.mall.admin.service.car;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.po.car.TCarEtcPO;
import com.zhuojy.equity.mall.admin.common.pojo.ResultEntity;
import com.zhuojy.equity.mall.admin.dal.mapper.car.TCarEtcMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author xrz
 * @version 1.0
 * @description:TODO
 * @date 2024/4/11 20:44
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TCarEtcService extends ServiceImpl<TCarEtcMapper, TCarEtcPO>  {
    public ResultEntity findetcrPagination(TCarEtcPO tCarMaintainPO, Integer pageSize, Integer pageNum) {
        Page<TCarEtcPO> page = new Page<>(pageNum, pageSize);
        IPage<TCarEtcPO> tCarMaintainPOIPage = this.baseMapper.findetcrPagination(tCarMaintainPO, page);
        return ResultEntity.OK(tCarMaintainPOIPage);
    }

    public ResultEntity addetc(TCarEtcPO tCarEtcPO) {
        tCarEtcPO.setEtcTime(new Date());
        this.baseMapper.insert(tCarEtcPO);
        return ResultEntity.OK("添加成功");
    }

    public ResultEntity upetc(TCarEtcPO tCarEtcPO) {
        this.baseMapper.updateById(tCarEtcPO);
        return ResultEntity.OK("操作成功");
    }

    public ResultEntity echoetc(Integer id) {
        TCarEtcPO tCarEtcPO = this.baseMapper.selectById(id);
        return ResultEntity.OK(tCarEtcPO);
    }

    public ResultEntity deletc(Integer id) {
        this.baseMapper.deleteById(id);
        return ResultEntity.OK("操作成功");
    }

    public ResultEntity getcaretc() {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.select("id","etc_id");
        List<TCarEtcPO> list = this.baseMapper.selectList(wrapper);
        return ResultEntity.OK(list);
    }
}
